package com.levelup.cr.model.entity;

import com.levelup.cr.model.Adaptable;
import com.levelup.cr.model.Node;

/**
 * Created with IntelliJ IDEA.
 * User: denis_zavadsky
 * Date: 8/31/13
 * Time: 11:04 AM
 * To change this template use File | Settings | File Templates.
 */
public class Product implements Adaptable {
    public static final String PROPERTY_NAME="name";
    public static final String PROPERTY_DESC="description";
    public static final String PROPERTY_PRICE="price";

    private String name;
    private String description;
    private Float price;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Float getPrice() {
        return price;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public static Adaptable adapt(Node node){
        Product product = new Product();
        product.setName((String)node.getProperties().get(PROPERTY_NAME));
        product.setDescription((String)node.getProperties().get(PROPERTY_DESC));
        product.setPrice((Float)node.getProperties().get(PROPERTY_PRICE));
        return product;
    }
}
